//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet
{
    ///<summary>
    /// Implements a set of predefined errors
    ///</summary>
    public static class Errors
    {
        public static Error GetError(ErrorType type)
        {
            switch (type)
            {
                case ErrorType.Div0: return DivError;
                case ErrorType.NA: return NaError;
                case ErrorType.Name: return NameError;
                case ErrorType.Null: return NullError;
                case ErrorType.Num: return NumError;
                case ErrorType.Ref: return new RefError(null);
                case ErrorType.Value: return ValueError;
                default: throw new NotSupportedException();
            }
        }
        public static Error RefError
        {
            get
            {
                return new RefError(null);
            }
        }

        
        ///<summary>
        /// Get a new name error
        ///</summary>
        public static Error NameError
        {
            get
            {
                return new Error(ErrorType.Name); //\\check
            }
        }
        public static Error NaError
        {
            get
            {
                return _naError;
            }
        }
        static readonly Error _naError = new Error(ErrorType.NA);
        public static Error NumError
        {
            get
            {
                return new Error(ErrorType.Num); //\\check
            }
        }
        public static Error NullError
        {
            get
            {
                return new Error(ErrorType.Null); //\\check
            }
        }
        public static Error ValueError
        {
            get
            {
                return new Error(ErrorType.Value);
            }
        }
        public static Error DivError
        {
            get
            {
                return new Error(ErrorType.Div0);
            }
        }

    }
}